package com.linkq.ipinyin.controller;

import com.linkq.ipinyin.model.Text;
import com.linkq.ipinyin.service.TextService;
import com.linkq.ipinyin.vo.ResultInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @FileName BcTextController
 * @Description
 * @Author wangpeng
 * @date 2024-11-12
 **/

@RestController
@RequestMapping("text")
public class TextController {
    @Autowired
    private TextService textService;

    @PostMapping("queryTextAndFile")
    public ResultInfo queryTextAndFile(@RequestBody Text text) {
        return ResultInfo.success(textService.queryTextAndFile(text));
    }

    @PostMapping("queryTextByCondition")
    public ResultInfo queryTextByCondition(@RequestBody Text text) {
        return ResultInfo.success(textService.queryTextByCondition(text));
    }

    @PostMapping("add")
    public ResultInfo add(@RequestParam(value = "picture", required = false) List<MultipartFile> pictures,
                          @RequestParam(value = "video", required = false) List<MultipartFile> video, Text text) {
        return ResultInfo.success(textService.add(pictures, video, text));
    }

    @PostMapping("delete")
    public ResultInfo delete(@RequestBody List<Integer> ids) {
        return textService.delete(ids);
    }

    @PostMapping("edit")
    public ResultInfo edit(@RequestParam(value = "picture", required = false) List<MultipartFile> picture,
                           @RequestParam(value = "video", required = false) List<MultipartFile> video, Text text) {
        return textService.edit(picture, video, text);
    }
}
